Skip to content

Add solver independent quantifier elimination with ultimate eliminator #462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 97 commits into
base: master
Choose a base branch
from

Conversation

Anastasia-Gu
Copy link
Collaborator

@Anastasia-Gu Anastasia-Gu commented Mar 20, 2025

  1. Added dependencies for UltimateEliminator in ivy.xml
  2. Integrated classes needed for UltimateEliminator in JavaSMT
  3. Created UltimateEliminatorWrapper class and equipped with a utility class UltimateEliminatorParser
  4. Created options in QuantifiedFormulaManager
  5. Added a Mathsat5QuantifiedFormulaManager
  6. Implemented the method EliminateQuantifiersUltimateEliminator in AbtractQuantifiedFormulaManager
  7. Implemented eliminateQuantifierBeforeMakingFormula in AbtractQuantifiedFormulaManager for when quantifier elimination is done before the native solver gets the formula.
    (To get the right formula information: with visitor get the name and type of bound variables)
  8. Tests

BaierD and others added 30 commits November 13, 2024 16:57
format code
add missing UltimateEliminator dependencies
…k most solvers (now 152 tests run over all solvers compared to 89 before)
@baierd
Copy link
Contributor

baierd commented Apr 2, 2025

@kfriedberger @PhilippWendler we have 3 warnings from Spotbugs that are empty in this PR. Do you happen to know the reason for this or how to find out?

@kfriedberger
Copy link
Member

kfriedberger commented Apr 2, 2025

image

  • UrF = Unread Field
  • UwF = Unwritten Field

Please check the code for unused fields or variables.

I also would like to have better Spotbugs messages. I assume this topic is more general and applies to more project at SoSy-Lab. I have not yet checked in CPAchecker or VCloud, whether SpotBugs prints so minimal errors there, too.

UPDATE:
Spotbugs at CPAchecker seems to provide better errror messages:
image

TODO:
Check whether JavaSMT uses the latest version of SpotBugs (no, it does not) and has set all required options for it?

@baierd
Copy link
Contributor

baierd commented Apr 7, 2025

Thanks for the help!
I guess we are currently not synced to the java project template of SoSy. I'm gonna update it this week!

@PhilippWendler
Copy link
Member

@kfriedberger @PhilippWendler we have 3 warnings from Spotbugs that are empty in this PR. Do you happen to know the reason for this or how to find out?

This is a known SpotBugs bug and fixed in version 4.9.0 (from January).

…verride it in Mathsat5QuantifiedFormulaManager
…r_elimination_with_ultimate_eliminator' into add_solver_independent_quantifier_elimination_with_ultimate_eliminator

# Conflicts:
#	src/org/sosy_lab/java_smt/delegate/debugging/DebuggingQuantifiedFormulaManager.java
#	src/org/sosy_lab/java_smt/delegate/statistics/StatisticsQuantifiedFormulaManager.java
#	src/org/sosy_lab/java_smt/delegate/synchronize/SynchronizedQuantifiedFormulaManager.java
Copy link
Contributor

@baierd baierd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your test classes test the options for quantifier creation and elimination explicitly. However, you could add a second or even third parameter to the parameterized test setup of SolverBasedTest0.ParameterizedSolverBasedTest0 (by extending it with a subclass or two). Then you could automatically check ALL option combinations with all solvers.

Also, please extend the documentation of the methods in the AbstractQuantifiedFormulaManager that deal with the interaction of UE with the solvers. They have very little to none currently.

return fmgr.orElseThrow();
}

public void setFmgr(AbstractFormulaManager<TFormulaInfo, TType, TEnv, TFuncDecl> pFmgr) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply set it in the AbstractFormulaManagers constructor for existing QuantifiedFormulaManagers?
Then its in the same package and can be package-private.
This would also prevent other developers from forgetting.

@Override
protected String dumpFormula(BooleanFormula bf) {
return ((Mathsat5FormulaManager) getFmgr())
.dumpFormulaImplExt(extractInfo(bf), "qFormulaNameMathsat5");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not out the implementation of dumpFormulaImplExt here?

@@ -39,14 +45,23 @@ public UltimateEliminatorWrapper(LogManager pLog) {
log = pLog;
}

/*
* Simplifies and try to remove the quantifiers from the given term using the UltimateEliminator.
*/
public Term simplify(Term pTerm) {
return ultimateEliminator.simplify(pTerm);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

UE has lots of options that allow different types of simplifications.
Do we have a way of changing those?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I understand it, we currently do not. As we would have to Override the "simplify" method in the UltimateEliminator source code to do so. I tried creating a class that extends UltimateEliminator to override the method, however, it ended with accessibility issues
See: https://github.com/ultimate-pa/ultimate/blob/0ed21c286de111155dccfbaf80bfbc5906a6435f/trunk/source/Library-ModelCheckerUtils/src/de/uni_freiburg/informatik/ultimate/lib/modelcheckerutils/smt/UltimateEliminator.java#L268

return wrap(eliminateQuantifiers(extractInfo(pF)));
} else {
} catch (Exception e1) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please never plainly catch Exception. Always catch named exceptions only.

}

case ULTIMATE_ELIMINATOR_FALLBACK_ON_FAILURE:
try {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are repeating the try-catch blocks quite a lot. You could extract them into a method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants